package net.dgg.dggcloud.service.jrcrm.service.customer;

import net.dgg.dggcloud.core.minidao.hibernate.dao.IGenericBaseCommonDao;
import net.dgg.dggcloud.service.common.base.service.BaseService;
import net.dgg.dggcloud.service.jrcrm.dao.customer.WidelyResourceRecordDao;
import net.dgg.dggcloud.service.jrcrm.entity.customer.WidelyResourceAllotRecord;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by 李韬 on 2018/1/5.
 * 线索分配记录业务处理
 */
@Service
public class WidelyResourceRecordService extends BaseService {

    @Resource
    private WidelyResourceRecordDao widelyResourceRecordDao;
    @Resource(name = "miniDaoHiberCommonDao")
    protected IGenericBaseCommonDao repository;

    /**
     * 保存
     * @param record
     */
    public void saveOneRecord(WidelyResourceAllotRecord record){
        repository.saveOrUpdate(record);
    }

    /**
     * 根据条件查询广泛资源的分配记录的列表
     * @param map
     * @return
     */
    public List<Map> queryRecordByCondtions(Map map){
        return widelyResourceRecordDao.queryWidelyRecordByCondition(map);
    }

    /**
     * 根据条件查询广泛资源的分配记录的列表 总数
     * @param map
     * @return
     */
    public Integer countRecordByCondtions(Map map){
        return widelyResourceRecordDao.countWidelyRecordByCondition(map);
    }

    /**
     * 获取广泛资源分配记录表中的 资源时间 去重后的列表
     * @param map currUserId 当前登录人的ID
     * @return
     */
    public List<Map> getDistinctResourceTimeList(Map map){
        return widelyResourceRecordDao.getDistinctResourceTimeList(map);
    }
}
